<template>
	<view class="container">
		<view class="position-relative">
			<view class='user_bg'></view>
		</view>
		<view style="padding: 0 30rpx;">
			<!-- user box begin -->
			<view class="d-flex flex-column bg-white user-box">
				<view class="d-flex align-items-center">
					<view class="avatar">
						<image :src="islogin ? detail.avatarUrl : '/static/images/mine/default.png'"></image>
						<view class="badge">
							<image src="/static/images/mine/level.png"></image>
							<view>{{ detail.grade.namel }}</view>
						</view>
					</view>
					<view class="d-flex flex-column flex-fill overflow-hidden" style="margin-top: 20rpx;">
						<view v-if="islogin" class="font-size-lg font-weight-bold d-flex justify-content-start align-items-center">
							<view class="text-truncate">{{ detail.nickName  }}</view>
						</view>
						<view v-else class="font-size-lg font-weight-bold">请点击授权登录</view>
					</view>
				</view>
				<!-- user grid begin -->
				<view class="w-100 d-a-c">
					<view class="user-grid" @click="gotoPage('/pages/user/my-coupon/my-coupon')">
						<view class="value f32 font-weight-bold text-color-base">
							{{  islogin ? coupon : '***' }}
						</view>
						<view class="f26 text-color-assist">优惠券</view>
					</view>
					<view class="user-grid" @click="gotoPage('/pages/user/points/points')">
						<view class="value f32 font-weight-bold text-color-base">
							{{  islogin ? detail.points : '***' }}
						</view>
						<view class="f26 text-color-assist">积分</view>
					</view>
					<view class="user-grid" @click="gotoPage('/pages/user/my-wallet/my-balance')">
						<view class="value f32 font-weight-bold text-color-base">
							{{  islogin ? detail.balance : '***' }}
						</view>
						<view class="f26 text-color-assist">余额</view>
					</view>
				</view>
				<!-- user grid end -->
			</view>
			<!-- user box end -->
		</view>
		<!-- service box begin -->
		<view class="service-box">
			<view class="font-size-lg text-color-base font-weight-bold" style="margin-bottom: 20rpx;">我的服务</view>
			<view class="row">
				<view class="grid" @click="gotoPage('/pages/plus/signin/signin')">
					<view class="image">
						<image src="/static/images/mine/jfqd.png"></image>
					</view>
					<view>积分签到</view>
				</view>
				<view class="grid" @click="gotoPage('/pages/plus/points/list/list')">
					<view class="image">
						<image src="/static/images/mine/nxsc.png"></image>
					</view>
					<view>积分商城</view>
				</view>
				<view class="grid" @click="callPhone()">
					<view class="image">
						<image src="/static/images/mine/lxkf.png"></image>
					</view>
					<view>联系客服</view>
				</view>
				<view class="grid" @click="gotoPage('/pages/user/address/address')">
					<view class="image">
						<image src="/static/images/mine/shdz.png"></image>
					</view>
					<view>收货地址</view>
				</view>
			</view>
		</view>
		<!-- service box end -->
	</view>
</template>

<script>
	import {mapState, mapGetters} from 'vuex'
	export default {
		data() {
			return {
				phone:'',
				islogin:false,
				user_type:1,
				newIcon: 'https://img-shop.qmimg.cn/s16/images/2020/05/12/ffb0613dded704b6.png',
				/*签到数据*/
				sign: {},
				/*是否加载完成*/
				loadding: true,
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				/*菜单*/
				menus: [],
				invitation:{},
				detail: {
					balance: 0,
					points: 0,
					grade: {
						name: ''
					},
				},
				orderCount: 0,
				coupon: 0,
				setting: {},
				takeStatus:0,
				ridermoney:'',
				refundStatus:0,
			}
		},
		onShow() {
			let self=this;
			setTimeout(function() {
				self.getData();
			}, 300);
			
		},
		methods: {
			/*获取数据*/
			getData() {
				console.log(1)
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._post('user.index/detail', {
					source: self.getPlatform()
				}, function(res) {
					//#ifdef MP-WEIXIN
					if (res.data.getPhone) {
						uni.navigateTo({
							url: "/pages/login/bindmobile"
						});
						return;
					}
					//#endif
					self.detail = res.data.userInfo;
					self.sign = res.data.sign;
					self.coupon = res.data.coupon;
					self.phone=res.data.phone+'';
					self.islogin=true;
					self.loadding = false;
					uni.hideLoading();
				});
			},
			login() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			balance() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/balance/balance'
				})
			},
			addresses() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/address/address'
				})
			},
			integrals() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/integrals/integrals'
				})
			},
			attendance() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/attendance/attendance'
				})
			},
			orders() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/orders/orders'
				})
			},
			memberCode() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/mine/member-code'
				})
			},
			coupons() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/coupons/coupons'
				})
			},
			userinfo() {
				if(!this.isLogin) {
					this.login()
					return
				}
				uni.navigateTo({
					url: '/pages/mine/userinfo'
				})
			},
			services() {
				uni.navigateTo({
					url: '/pages/services/services'
				})
			},
			callPhone(){
				let self=this;
				let phone=self.phone+"";
				console.log(phone)
				uni.makePhoneCall({
					phoneNumber: phone,
					success(res) {
						console.log(res)
					},fail(err) {
						console.log(err)
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
page {
	height: auto;
	min-height: 100%;
}	

.bg {
	width: 100%;
	height: calc(410 / 594 * 750rpx);
}

.hym-btn {
	position: absolute;
	top: 40rpx;
	right: 40rpx;
	color: $color-primary;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50rem;
	font-size: $font-size-sm;
	box-shadow: 0 0 20rpx rgba(66,66,66,0.1);
	&::after {
		border: 0;
	}
	
	image {
		width: 30rpx;
		height: 30rpx;
		margin-right: 10rpx;
	}
}

.user-box {
	position: relative;
	border-radius: 8rpx; 
	margin-bottom: 30rpx;
	margin-top: -115rpx;
	box-shadow: $box-shadow;
}

.avatar {
	position: relative;
	margin-top: -35rpx;
	margin-left: 35rpx;
	margin-right: 35rpx;
	width: 160rpx;
	height: 160rpx;
	border-radius: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #FFFFFF;
	box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
	
	image {
		width: 140rpx;
		height: 140rpx;
		border-radius: 100%;
	}
	
	.badge {
		position: absolute;
		right: -10rpx;
		bottom: -10rpx;
		background-color: #FFFFFF;
		border-radius: 50rem;
		display: flex;
		align-items: center;
		justify-content: center;
		color: $color-warning;
		font-size: 24rpx;
		padding: 8rpx 16rpx;
		box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
		
		image {
			width: 30rpx;
			height: 30rpx;
		}
	}
}

.level-benefit {
	margin-left: 35rpx;
	padding: 10rpx 0 10rpx 30rpx;
	border-radius: 50rem 0 0 50rem;
}

.user-grid {
	width: 25%;
	padding: 30rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	
	.value {
		margin-bottom: 20rpx;
	}
}

.level-benefit-box {
	border-radius: 8rpx; 
	margin-bottom: 30rpx;
	box-shadow: 0 10rpx 8rpx rgba($color: #878889, $alpha: 0.1);
	width: 100%;
	display: flex;
	padding: 30rpx;
	flex-direction: column;
	background-color: #FFFFFF;
	
	.row {
		display: flex;
		padding: 30rpx 0 20rpx;
		justify-content: space-around;
		align-items: center;
		
		.grid {
			width: 20%;
			display: flex;
			flex-direction: column;
			font-size: $font-size-sm;
			color: $text-color-assist;
			align-items: center;

			image {
				width: 80rpx;
				height: 80rpx;
				margin-bottom: 10rpx;
			}
		}
	}
}

.banner {
	width: 100%;
	padding: 0 30rpx;
	border-radius: 8rpx;
	margin-bottom: 30rpx;
}

.service-box {
	width: 100%;
	background-color: #FFFFFF;
	padding: 32rpx 30rpx 10rpx;
	box-shadow: $box-shadow;
	
	.row {
		display: flex;
		flex-wrap: wrap;
		color: $text-color-assist;
		font-size: $font-size-sm;
		padding-bottom: -40rpx;
		
		.grid {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			margin-bottom: 40rpx;
			width: 25%;
			position: relative;
			
			.image {
				image {
					width: 88rpx;
					height: 88rpx;
					margin-bottom: 20rpx;
				}
			}
			
			.new-badage {
				width: 40rpx;
				height: 40rpx;
				position: absolute;
				top: 0;
				right: 30rpx;
			}
		}
	}
}
.user_bg{
	width: 100%;
	height: 300rpx;
	background-image: linear-gradient(to right, #ffad54 , #f08318);
}
.raider_apply{
	background-color: #FFE9E1;
	color:#DA7A21;
	height: 80rpx;
	line-height: 80rpx;
	text-indent: 30rpx;
	font-size: 26rpx;
	margin: 20rpx 0;
}
.raider_info{
	height: 260rpx;
	margin: 20rpx 0;
	background-color: #FFFFFF;
	padding: 30rpx;
	padding-bottom: 0;
	display: flex;
	flex-direction: column;
}
.raider_info .icon-jiantou{
	text-align: right;
	margin-left: 14rpx;
	font-size: 26rpx;
	
}
.raider_item{
	border-top: 1rpx solid #d9d9d9;
	flex: 1;
	height: 100%;
}
.item_rb{
	border-right:  1rpx solid #d9d9d9;
}
</style>
